import {BrowserModule, DomSanitizer} from '@angular/platform-browser';
import {NgModule} from '@angular/core';

import {NavigationModule} from './module/navigation/navigation.module';
import {AppComponent} from './app.component';
import {NZ_I18N, zh_CN} from 'ng-zorro-antd';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {registerLocaleData} from '@angular/common';
import zh from '@angular/common/locales/zh';
import {AuthGuard} from './service/guard/auth.guard';
import {CanDeactivateGuard} from './service/guard/can-deactivate.guard';
import {AppRoutingModule} from './app-routing.module';
import {SecurityModule} from './module/security/security.module';
import {MenuParamDictService} from './service/menu-param-dict.service';
import {TagDictService} from './service/tag-dict.service';

// import {InterceptorService} from './service/interceptor/interceptor-service';
import {ApplicationService} from './service/application.service';
import {MatIconRegistry} from '@angular/material';
import {CommonInterceptor} from './service/interceptor/CommonInterceptor';
import {SetofDictService} from './service/setof-dict.service';
import {TagService} from './service/tag.service';
import {MenuParamService} from './service/menu_param.service';
// import {RequestOptions} from 'http';


registerLocaleData(zh);
// export function interceptorFactory( requestInterceptor: RequestInterceptor) {
//   // Add it here
//   let service = new InterceptorService();
//   service.addInterceptor(requestInterceptor); // Add it here
//   return service;
// }
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    AppRoutingModule,
    SecurityModule,
    NavigationModule,
    BrowserAnimationsModule,
  ],
  providers: [
    {provide: NZ_I18N, useValue: zh_CN},
    {
      provide: HTTP_INTERCEPTORS,
      useClass: CommonInterceptor,
      multi: true // Add it here, in the same order as the signature of interceptorFactory
    },
    AuthGuard,
    TagDictService,
    TagService,
    MenuParamService,
    SetofDictService,
    MenuParamDictService,
    CanDeactivateGuard
  ],
  bootstrap: [AppComponent]
})

export class AppModule {

  /**
   * Creates an instance of AppModule.
   * @param {MdIconRegistry} mdIconRegistry
   * @param {DomSanitizer} domSanitizer
   * @param {ApplicationService} applicationService
   * @memberof AppModule
   */
  public constructor(
    private mdIconRegistry: MatIconRegistry,
    private domSanitizer: DomSanitizer,
    private applicationService: ApplicationService,
  ) {
    this.registryResources();
  }

  /**
   * 注册资源
   *
   * @memberof AppModule
   */
  public registryResources() {
    //SVG图标资源注册
    this.mdIconRegistry.addSvgIconInNamespace('assets', 'logo', this.domSanitizer.bypassSecurityTrustResourceUrl('./assets/images/logo.svg'));
    this.mdIconRegistry.addSvgIconInNamespace('assets', 'circle1', this.domSanitizer.bypassSecurityTrustResourceUrl('./assets/images/circle1.svg'));
    this.mdIconRegistry.addSvgIconInNamespace('assets', 'lamp', this.domSanitizer.bypassSecurityTrustResourceUrl('./assets/images/lamp.svg'));
    this.mdIconRegistry.addSvgIconInNamespace('assets', 'turbine', this.domSanitizer.bypassSecurityTrustResourceUrl('./assets/images/turbine.svg'));
  }
}
